﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NCT.INVPOS.DataAccessLayer.Entity;

namespace NCT.INVPOS.DataAccessLayer.Configurations
{
    public class SupplierConfiguration : EntityTypeConfiguration<Supplier>
    {
        public SupplierConfiguration()
        {
            HasKey(P => P.Id);

            Property(P => P.LastName).IsRequired().HasMaxLength(30);

            Property(P => P.FirstName).IsOptional().HasMaxLength(30);

            Property(P => P.MiddleName).IsOptional().HasMaxLength(30);

            Property(P => P.Address).IsOptional().HasMaxLength(100);

            Property(P => P.Code).IsOptional().HasMaxLength(30);

            Property(P => P.Contact).IsOptional().HasMaxLength(30);

            Property(P => P.ContactExt).IsOptional().HasMaxLength(5);

            Property(P => P.Email).IsOptional().HasMaxLength(40);

            Property(P => P.Fax).IsOptional().HasMaxLength(20);

            HasMany(P => P.Products).WithOptional(P => P.Supplier).HasForeignKey(P => P.SupplierId);
        }
    }
}
